


#pragma once

#include "stdio.h"


/**
 *
 *
 *
 */
template < typename TYPE >
class BASE_SINGLETON
{
public:
	bool			is_init( void )						{ return NULL != instance; }
	static TYPE*	get_instance( void )				{ return instance; }

protected:
	BASE_SINGLETON( void )
	{
	}
	virtual ~BASE_SINGLETON( void )
	{

	}

public:
	void			initialize( void )
	{
		//ASSERT( !is_init() );
		instance = new TYPE;
	}

	void			close( void )
	{
		//ASSERT( is_init() );
		delete instance;
		instance = NULL;
	}

private:
	BASE_SINGLETON(BASE_SINGLETON&);

private:
	static TYPE*		instance;
};



#define ASSIGN_SINGLETON(classname)		template <> classname* BASE_SINGLETON< classname >::instance = NULL;